<?php $yearstr=$str->getafteryear(0);?>         	
<?php 
$user=$session->read('User');
$companyid=$session->read("companyid");
?>
<div class="right_side_operate_area">
	<div class="right_side_title left">
		<h2>
		<?php 
		$companyname=$session->read("companyname");
		echo $html->link($companyname,"/companys/showinfosummary/".$companyid);
		?>
		</h2>
		<div class="clear"></div>
	</div>
    <div class="right item_add_btn">
    <?php 
    	$id=$form->value('CompPerson.id');
    	$str_title=__("Add",true);
		if($id){
			$str_title=__("Edit",true);
		}
		echo $html->link(__("Cancel",true).$str_title,"/companys/person/");
    ?>
    </div>
    <div class="clear"></div>
</div>
<div class="right_side_scollbar">
    <div class="detail_info_panel">
    	<?php echo $form -> create('persons', array('url' => '/companys/editperson/','type'=> 'post','onsubmit'=>'return checksave()') ); ?>
 		 <?php 
        	$radiovalue=array("1"=>"是","0"=>"否");
        	$sexvalue=array("1"=>"男","0"=>"女");
         	$attributes=array('legend'=>false);
        ?>
        <div class="details_item_line">
            <div class="details_item">
                <div class="form_left_title left">入职年份：</div>
                <div class="form_right_input left">
                	<?php 
                		$selectyear=null;
                		$id=$form->value("CompPerson.id");
                		if(empty($id)){
                			$selectyear=date("Y",strtotime("now"));
                		}
	                	echo $form->select('CompPerson.person_year',$yearstr, $selectyear, null,null)
                	?>
                </div>
            </div>  
            <div class="details_item">
                <div class="form_left_title left">姓名：</div>
                <div class="form_right_e_input  left"><?php echo $form->text('CompPerson.person_name',array("maxlength"=>"10"));?></div>
                <div id='personnamemessage' style='display:none;' class="error_message">请输入姓名</div>
            </div> 
      	</div>
 		<div class="details_item_line"> 
            <div class="details_item">
                <div class="form_left_title left">性别：</div>
                <div class="form_right_input left"><?php echo $form->radio('CompPerson.sex',$sexvalue,$attributes);?></div>
            </div>
            <div class="details_item">
                <div class="form_left_title left">出生年月：</div>
                <div class="form_right_e_input form_date_picker left"><?php echo $form->text('CompPerson.birthday',array("maxlength"=>"10","onfocus"=>"WdatePicker()","style"=>"width:130px"));?></div>
            </div>
        </div>
        <div class="details_item_line">
            <div class="details_item">
                <div class="form_left_title left">籍贯：</div>
                <div class="form_right_e_input left"><?php echo $form->text('CompPerson.native_place',array("maxlength"=>"20"));?></div>
            </div>
        	 <div class="details_item">
                <div class="form_left_title left">毕业院校：</div>
                <div class="form_right_e_input left"><?php echo $form->text('CompPerson.school',array("maxlength"=>"50"));?></div>
            </div>
        </div>
        <div class="details_item_line"> 
            <div class="details_item">
                <div class="form_left_title left">最高学历：</div>
                <div class="form_right_input left"><?php echo $form->select('CompPerson.education',$educations, null,null,null)?></div>
            </div>
            <div class="details_item">
                <div class="form_left_title left">毕业时间：</div>
              	<div class="form_right_e_input form_date_picker left"><?php echo $form->text('CompPerson.graduation_date',array("maxlength"=>"10","onfocus"=>"WdatePicker()","style"=>"width:130px"));?></div>
           	</div>
       	</div>
        <div class="details_item_line">  
           	<div class="details_item">
                <div class="form_left_title left">所学专业：</div>
                <div class="form_right_e_input left"><?php echo $form->text('CompPerson.major',array("maxlength"=>"20"));?></div>
            </div>
            <div class="details_item">
                <div class="form_left_title left">技术职称：</div>
                <div class="form_right_e_input left"><?php echo $form->text('CompPerson.technical_title',array("maxlength"=>"20"));?></div>
            </div>
        </div>
        <div class="details_item_line"> 
            <div class="details_item">
                <div class="form_left_title left">联系地址：</div>
                <div class="form_right_e_input left"><?php echo $form->text('CompPerson.address',array("maxlength"=>"200"));?></div>
            </div>
            <div class="details_item">
                <div class="form_left_title left"><?php __("Tel")?>：</div>
                <div class="form_right_e_input left"><?php echo $form->text('CompPerson.tel',array("maxlength"=>"20"));?></div>
            	<div id='telmessage' style='display:none;' class="error_message">请输入联系电话</div>
            </div>
        </div>
        <div class="details_item_line"> 
            <div class="details_item">
                <div class="form_left_title left">负责方向：</div>
                <div class="form_right_input left"><?php echo $form->select('CompPerson.contypeid',$contype, null,null,null);?></div>
                <div id='contypeidmessage' style='display:none;' class="error_message">请选择负责方向</div>
            </div>
         	<div class="details_item">
           	<div class="form_left_title left"><?php __("Mail")?>：</div>
                <div class="form_right_e_input left"><?php echo $form->text('CompPerson.email',array("maxlength"=>"50","style"=>"ime-mode:disabled"));?></div>
                <?php echo $form->text('User.uemail',array("class"=>"txthide","value"=>$form->value('CompPerson.email')));?>
                <div id='personemailmessage' style='display:none;' class="error_message">邮箱格式不正确</div>
            </div>
        </div>
        <div class="details_item_line">
        	<div class="details_item">
                <div class="form_left_title left">核心团队：</div>
                <div class="form_right_input left"><?php echo $form->radio('CompPerson.is_core',$radiovalue,$attributes);?></div>
            </div>
            <div class="details_item">
                <div class="form_left_title left">留学人员：</div>
                <div class="form_right_input left"><?php echo $form->radio('CompPerson.is_stuoversea',$radiovalue,$attributes);?></div>
            </div>
        </div>
        <div class="details_item_line">
            <div class="details_item">
                <div class="form_left_title left">科技人员：</div>
                <div class="form_right_input left"><?php echo $form->radio('CompPerson.is_technical',$radiovalue,$attributes);?></div>
            </div>
            <div class="details_item">
                <div class="form_left_title left">研发人员：</div>
                <div class="form_right_input left"><?php echo $form->radio('CompPerson.is_rd',$radiovalue,$attributes);?></div>
            </div>
        </div>
        <div class="details_item_line">
            <div class="details_item">
                <div class="form_left_title left">实习人员：</div>
                <div class="form_right_input left"><?php echo $form->radio('CompPerson.is_intern',$radiovalue,array('legend'=>false,'onclick'=>'setintern_days(this)'));?></div>
            </div>
            <div class="details_item">
                <div class="form_left_title left">应届毕业生：</div>
                <div class="form_right_input left"><?php echo $form->radio('CompPerson.is_newgraduates',$radiovalue,$attributes);?></div>
            </div>
        </div>
        <?php 
        	$daydisplay="none";
        	$isintern=$form->value('CompPerson.is_intern');
        	if($isintern){
        		$daydisplay="block";
        	}
        ?>
        <div class="details_item_line" id="intern_days" style="display:<?php echo $daydisplay ?>">
            <div class="details_item">
                <div class="form_left_title left">实习天数：</div>
                <div class="form_right_e_input left"><?php echo $form->text('CompPerson.intern_days',array('maxlength'=>'6',"style"=>"ime-mode:disabled",'onkeydown'=>'inputOnlyNum(event)','onkeypress'=>'checkIfNum(event)'));?></div>
            	<div id='personinterndays' style='display:none;' class="error_message">请输入实习天数</div>
            </div>
        </div>
        
        <div class="details_item_line edit_form_btn">
            <div class="details_item">
            	<div class="form_left_title left"></div>
                <div class="form_add_submit left">
	                <?php echo $form->submit(__('Save',true), array("div"=>false)) ?>
	                <?php  echo $form->hidden('CompPerson.id'); ?>
                </div>
            </div>
        </div>
        </form>
    </div>
</div>
<script>
var webpath=$("#getpath").attr('href');
$("#CompPersonEmail").keyup(function() {  
 	var mail=this.value;
 	var umail=$("#UserUemail").val();
 	checkuserbymail(webpath,mail,umail,"#personemailmessage");
});  	
function setintern_days(obj)
{
	var isflag=obj.value;
	if(isflag=="1"){
		$("#intern_days").attr("style","display:block");
	}else{
		$("#intern_days").attr("style","display:none");
	}
}
function checksave()
{
	var companytame=$("#CompPersonPersonName").val();
	var companydays=$("#CompPersonInternDays").val();
	
	if(companytame.trim() == ''){
		$("#personnamemessage").css('display','block');
		return false;
	}
	else{
		$("#personnamemessage").css('display','none');
	}
	
		var tel=$("#CompPersonTel").val();
		var mail=$("#CompPersonEmail").val();
		var contypeid=$("#CompPersonContypeid").val();
		if(tel.trim() == ''){
			$("#telmessage").css('display','block');
			return false;
		}
		else{
			$("#telmessage").css('display','none');
		}
		if(mail.trim() == ''){
			$("#personemailmessage").css('display','block');
			$("#personemailmessage").html("请输入联系邮箱");
			return false;
		}else if(!checkEmail(mail.trim())){
			$("#personemailmessage").css('display','block');
			$("#personemailmessage").html("联系邮箱格式不正确");
			return false;
		}else{
			$("#personemailmessage").css('display','none');
		}
		if(contypeid.trim() == ''){
			$("#contypeidmessage").css('display','block');
			return false;
		}
		else{
			$("#contypeidmessage").css('display','none');
		}
	var isIntern1=$('#CompPersonIsIntern1').attr("checked");
	if(companydays.trim() == '' && isIntern1=="checked"){
		$("#personinterndays").css('display','block');
		return false;
	}else{
		$("#personinterndays").css('display','none');
	}
	if($("#personemailmessage").css('display')=="block")
	{
		return false;
	}
	return true;
}
</script>